package com.zjut.azhen.DBDesign.component;

import com.zjut.azhen.DBDesign.bean.Role;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component

public class AdminHandlerInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Role role=(Role) request.getSession().getAttribute("role");
        System.out.println(role);
        if("R01".equals(role.getRno())){
            //是管理员,发送未登录消息
            return true;
        }
        request.getRequestDispatcher("/auth/unadmin").forward(request,response);

        return false;
    }
}
